home *** CD-ROM | disk | FTP | other *** search
/ PCMania 44 / PCMania CD44_1.iso / pcmania / treal44 / aviles / 3dbasics.h < prev    next >
C/C++ Source or Header  |  1996-04-07  |  5KB  |  155 lines

  1. /******************************************************************
  2.  **
  3.  **
  4.  **      Versión 3DBasics Diciembre 1995
  5.  **      Revisión de la base de datos
  6.  **
  7.  **      Copyright: Francisco Javier Avilés Navarro 1995
  8.  **
  9.  **      Intento de superar la barrera de los 60000 tr/seg en un
  10.  **      486 DX2 66 Mhz sin hardware adicional
  11.  **
  12.  **      ---------------------------------------------------------
  13.  **
  14.  **      I'm trying to reach the 60000-tr-sec's barrel in a DX266
  15.  **
  16.  *******************************************************************/
  17.  
  18. #include <math.h>
  19. #ifdef GNU_C
  20. #include <grx.h>
  21. #include <mousex.h>
  22. #elif BORLAND_C
  23. #include <graphics.h>
  24. #include <mem.h>
  25. #include <dos.h>
  26. #endif
  27. #include <conio.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30.  
  31. #define DOBLETPANTX  640
  32. #define DOBLETPANTY  340
  33. #define MAXPANTX  640
  34. #define MAXPANTY  410
  35. #define LONGBUFZ LARGOZOB*2
  36.  
  37. #ifdef GNU_C
  38. extern GrContext *Donde_dibujo,*Lo_que_muestro;
  39. extern MouseEvent evt;
  40. #endif
  41. extern char far *dir;
  42. extern int total,totol;
  43. #ifdef TEXTURAS
  44. extern char far texturasPCX[TAMPCX];
  45. #endif
  46. typedef struct triangulo {
  47.     double normal[3];
  48.     short color,s_color,tipo;
  49.     short representado; /* a 0 si no-rep,1 si si-rep*/
  50.     struct Xon *on_first[4]; /*para señalar correctam*/
  51.     struct triangulo *siguiente;
  52.     char *textura;
  53.     };
  54.  
  55. typedef struct enlaceXon{
  56.     struct triangulo *sig;
  57.     struct enlaceXon *enlazado;
  58.     };
  59.  
  60. typedef struct Xon {
  61.     struct enlaceXon *lista,*ultimo_lista;
  62.     short indice,xp,yp;
  63.     double x,y,z;
  64.     double normal[3];
  65.     int xo[3];
  66.     struct CUERPO *propietario;
  67.     struct Xon *anterior,*siguiente;
  68.     struct Xon *anteriorZ,*siguienteZ;
  69.     struct Xon *siguienteCuerpo;
  70.     };
  71.  
  72.  
  73. typedef struct CUERPO{
  74.                struct Xon *first,*en_curso;
  75.                struct triangulo *trfirst,*trlast;
  76.                double kd,ke;
  77.               /* double coeficientes[3][16];
  78.                char nombre[20];*/
  79.              };
  80.  
  81.  
  82. typedef struct luz_lejana{
  83.     double direccion[3];
  84.     };
  85. struct luz_lejana LUZ_LEJANA;
  86.  
  87. typedef struct luz_cercana{
  88.     double direccion[3];
  89.     double punto[3];
  90.     double distancia,apertura_luz;
  91.     };
  92. struct luz_cercana LUZ_CERCANA;
  93.  
  94. extern char  *basura,*basura_un,*al_vector_un;
  95.  
  96. extern double trans_mat [3][3],comodin[3][3];
  97.  
  98. extern struct Xon *x0un [2];
  99. extern struct Xon *z0ob [LONGBUFZ];
  100.  
  101. extern int contropant,contro_vector_un;  /** controladores de estado de dispositivos **/
  102. extern int MaxX,MaxY;
  103. extern struct Xon *unx,*otrox;
  104. extern struct Xon *unz,*otroz;
  105. extern struct triangulo *TRIANG;
  106. #ifdef STEREO
  107. extern int izqdo;
  108. #endif
  109. extern int visx,visy,visz,mix,miy,miz; /* Estas variables son las coordernadas
  110.                    del punto de vista y el de mira        */
  111. extern int  xmin,xmax,ymax,ymin,zmax,zmin; /* Coordenadas del cubo de visión      */
  112. extern int  neary; /**** Distancia hasta la pantalla desde el ojo                  */
  113. extern int Z,X;
  114. extern int evaluador;
  115.  
  116. #ifdef GNU_C
  117. void Initialize(int modo,int tam_buf_obs,int tam_buf_un,int tam_buf_vu);
  118. #elif BORLAND_C
  119. void Initialize(int busca,int modo,unsigned long tam_buf_obs,unsigned long tam_buf_un,unsigned long tam_buf_vu);
  120. #endif
  121. void multmat (double matriz1[3][3],double matriz2[3][3]);
  122. void multvec(int matriz1[3],double matriz2[3][3]);
  123. void multvect(double matriz1[3],double matriz2[3][3]);
  124. void lookat(int vx,int vy,int vz,int px,int py,int pz,int twist);
  125. void perspective(double fovy,double aspect,long cercano,long lejano);
  126. void a_observador(void);
  127. void coloca_punto (int x_on,int y_on,int z_on,struct triangulo *donde,int num_vert,struct CUERPO *);
  128. struct triangulo * forma_tetrangulo (double punto_1[3],double punto_2[3],double punto_3[3],double punto_4[3],int color,int textur,char *s,struct CUERPO *quien);
  129. void a_pantalla(void);
  130. void a_pantalla_plano(void);
  131. void a_pantalla_phong(void);
  132. struct triangulo *forma_recta (double punto_1[3],double punto_2[3],int color,struct CUERPO *quien);
  133. struct triangulo *forma_punto (double punto_1[3],int color,struct CUERPO *quien);
  134. void forma_superf_ab (struct superab *surfab);
  135. void rota_tetrangs(struct CUERPO *DIR_TR2,int p1[3],int p2[3],double ANG,int);
  136. void trans_tetrangs(struct CUERPO *DIR_TR2,double tx,double ty,double tz);
  137. void trans(struct triangulo *DIR_TR2,double tx,double ty,double tz);
  138. void trans_copy(struct CUERPO *origen,struct CUERPO *dest,
  139. double tx,double ty,double tz);
  140. void cerrar_sistema();
  141. int sentido();
  142. void promedia_normales(struct CUERPO *quien);
  143. void Manage();
  144. int getPCX (char *argv,char far *donde,unsigned int lugar_en_paleta,int *anchura,int *altura);
  145. #ifdef RV
  146. extern double ang_cenital;
  147. extern double ang_z;
  148. extern double radio;
  149. int control_key(int AEREO,int radio_max);
  150. #endif
  151. #ifdef STEREO
  152. void stereo();
  153. #endif
  154. void grabar_como_RAX(char *ss);
  155.